<template>
  <el-dialog v-model="visible" title="打印记录">
    <el-table
      stripe
      border
      ref="tableRef"
      v-loading="loading"
      :data="tableData"
      key="id"
    >
      <el-table-column type="index" label="序号" width="55" />
      <el-table-column prop="labelCode" label="标签条编码" />
      <el-table-column prop="labelName" label="标签条名称" />
      <el-table-column prop="custPoints" label="客户积分数" />
      <el-table-column prop="salemanPoints" label="业务员积分数" />
    </el-table>

    <el-pagination
      background
      class="mt-4"
      :total="total"
      :page-size="queryData.pageSize"
      :page-sizes="[10, 20, 50, 100]"
      layout="total, prev, pager, next"
      @current-change="handleCurrentChange"
      @size-change="handleSizeChange"
    />
  </el-dialog>
</template>
<script setup>
import { ref } from "vue";
// import { ElMessage, ElMessageBox } from "element-plus";
import api from "@/api/label.js";

const props = defineProps({
  typeName: { type: String, default: "新增" },
});
const visible = ref(false);
const tableData = ref([]);
const tableRef = ref();
const total = ref(0);
const queryData = ref({
  pageNo: 1,
  pageSize: 10,
});
const loading = ref(false);
const emits = defineEmits(["success"]);

const initData = async () => {
  loading.value = true;
  try {
    const res = await api.printLogDetail(queryData.value);
    tableData.value = res.data.list;
    total.value = res.data.total;
  } finally {
    loading.value = false;
  }
};

const handleCurrentChange = (val) => {
  queryData.value.pageNo = val;
  initData();
};
const handleSizeChange = (val) => {
  queryData.value.pageSize = val;
  initData();
};

const openDialog = () => {
  visible.value = true;
  tableData.value = [];
  handleCurrentChange(1);
};

defineExpose({
  openDialog,
});
</script>
